package com.mrdeer.iot.bean.command;

import com.mrdeer.iot.utils.HexHelper;

/**
 * 指令
 *
 * @Author: xie jianchu
 */
public interface Instruction {

    interface ControlFrame {

        /**
         * 整机指令
         */
        interface complete_machine {
            int search = 0x0100;        //查询
            int mute_open = 0x0201;     //静音开启
            int mute_close = 0x0200;    //静音关闭
            int speech1 = 0x0300;       //语音播报
            int speech2 = 0x0301;
            int speech3 = 0x0302;
            int speech4 = 0x0303;
        }

        /**
         * 洗涤仓指令
         */
        interface wash_machine {
            int authorization = 0x1001;     //授权
            int deauthorize = 0x1000;       //解除授权
            int wash_start = 0x1101;        //洗涤仓开启
            int wash_stop = 0x1100;         //洗涤仓暂停
            int wash_await = 0x1500;        //洗涤仓待机
            int wash_open_door = 0x1201;    //洗涤仓开门
            int wash_close_door = 0x1200;   //洗涤仓关门
        }

        interface drying_1 {
            int authorization = 0x1001;     //授权
            int deauthorize = 0x1000;       //解除授权
            int dry_start = 0x1101;        //烘干仓1开启
            int dry_stop = 0x1100;         //烘干仓1暂停
            int dry_await = 0x1500;        //烘干仓1待机
        }

        interface drying_2 {
            int authorization = 0x1001;     //授权
            int deauthorize = 0x1000;       //解除授权
            int dry_start = 0x1101;        //烘干仓2开启
            int dry_stop = 0x1100;         //烘干仓2暂停
            int dry_await = 0x1500;        //烘干仓2待机
        }

        /**
         * 程序设定
         */
        interface program_set {
            //洗涤仓命令
            int wash_null = 0x1600;
            int wash_auto = 0x1601;
            //烘干仓1
            int drying_1_null = 0x2600;
            int drying_1_auto = 0x2601;
            int drying_1_sterilize = 0x2602;
            //烘干仓2
            int drying_2_null = 0x3600;
            int drying_2_auto = 0x3601;
            int drying_2_sterilize = 0x3602;
        }
    }

    interface InvalidFrame {
        byte invalid_command = 0x00;    //无效命令
        byte program_error = 0x01;      //程序选择错误,暂未使用
        byte program_running = 0x02;    //程序运行时不能设置,程序正在运行,或按过启动按键
        byte program_out_range = 0x03;   //所设参数超出程序允许范围,档位、可调参数等超出范围（预约,程序等）
        byte program_set_error = 0x04;      //设定的参数错误或超范围
    }

    /**
     * 故障码
     */
    interface ErrorFrame {
        byte CLEAR_ALERT = 0x00;            //报警解除
        byte DRAINING_TIMEOUT = 0x01;       //排水超时
        byte UNCAP_ALERT = 0x02;            //开盖报警
        byte INFLOW_TIMEOUT = 0x03;         //进水超时
        byte WATER_LEVEL_SENSOR_ERROR = 0x04;   //水位传感器异常
        byte WATER_OVERFLOW = 0x05;         //水位溢出
        byte SHAMPOO_OUT = 0x06;            //洗鞋液不足
    }

    public static void main(String[] args) {
        System.out.println(HexHelper.numToHex32(ErrorFrame.CLEAR_ALERT));
        System.out.println(HexHelper.numToHex8(ErrorFrame.DRAINING_TIMEOUT) + HexHelper.numToHex8(ErrorFrame.UNCAP_ALERT));
        System.out.println(HexHelper.numToHex16(ControlFrame.complete_machine.search));
    }
}
